package com.fcat.common.user.rpc;

import com.alibaba.fastjson.JSONArray;
import com.fcat.common.user.vo.AdminClient;
import com.fcat.common.user.vo.AdminClientRole;
import feign.hystrix.FallbackFactory;
import org.keycloak.representations.AccessTokenResponse;
import org.keycloak.representations.idm.CredentialRepresentation;
import org.keycloak.representations.idm.UserRepresentation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.util.MultiValueMap;

import java.util.List;


/**
 * Project Name: user-center
 * Package Name: com.higovnet.user.center.feign.impl
 *
 * @author：Liubinwang
 * @date：2018/9/30 9:53
 * Copyright (c) 2018,higovnet.net All Rights Reserved.
 */
@Component
public class KeycloakFeignFailFactory implements FallbackFactory<KeycloakFeign> {

    private final Logger log = LoggerFactory.getLogger(this.getClass());

    @Override
    public KeycloakFeign create(Throwable throwable) {
        return new KeycloakFeign() {
            @Override
            public AccessTokenResponse token(String authorization, String realm, MultiValueMap<String, String> params) {
                return null;
            }

            @Override
            public void createUser(String authorization, String realm, UserRepresentation user) {
                System.err.println("1424");

            }

            @Override
            public JSONArray findUser(String authorization, String realm, String username) {
                return null;
            }

            @Override
            public void resetPassword(String authorization, String realm, String id, CredentialRepresentation credentialRepresentation) {

            }

            @Override
            public UserRepresentation getUserInfo(String authorization, String realm, String userId) {
                return null;
            }


            @Override
            public void logout(String authorization, String realm, String userId) {

            }

            @Override
            public void deleteSession(String authorization, String realm, String sessionId) {
                log.error("deleteSession 失败");
            }

            @Override
            public List<AdminClientRole> roles(String authorization, String realm, String clientId) {
                return null;
            }

            @Override
            public void deleteUser(String authorization, String realm, String userId) {

            }

            @Override
            public List<AdminClientRole> available(String authorization, String realm, String userId, String clientId) {
                log.error("available 失败");
                return null;
            }

            @Override
            public List<AdminClientRole> composite(String authorization, String realm, String userId, String clientId) {
                log.error("composite 失败");
                return null;
            }

            @Override
            public List<AdminClientRole> allocateRoles(String authorization, String realm, String userId, String clientId, List<AdminClientRole> clientRoles) {
                log.error("allocateRoles 失败");
                return null;
            }

            @Override
            public List<AdminClientRole> deleteRoles(String authorization, String realm, String userId, String clientId, List<AdminClientRole> clientRoles) {
                log.error("deleteRoles 失败");
                return null;
            }


            @Override
            public List<AdminClient> clients(String authorization, String realm) {
                return null;
            }

        };
    }
}
